import Vec3 from "../common/vec3";
import CONSTANT from "../constant";
import DetectorResultPoint from "./detector-result-point";

export default class DetectorResult {
    constructor() {
        this.numPoints = 0;
        this.normal = new Vec3();
        this.points = new Array(CONSTANT.SETTING_MAX_MANIFOLD_POINTS);
        this.incremental = false;
        let _g = 0, _g1 = CONSTANT.SETTING_MAX_MANIFOLD_POINTS;
        while(_g < _g1) this.points[_g++] = new DetectorResultPoint();
    }
    getMaxDepth() {
        let max = 0;
        let _g = 0, _g1 = this.numPoints;
        while(_g < _g1) {
            let i = _g++;
            if(this.points[i].depth > max) {
                max = this.points[i].depth;
            }
        }
        return max;
    }
    clear() {
        this.numPoints = 0;
        let _g = 0, _g1 = this.points;
        let v=null;
        while(_g < _g1.length) {
            let p = _g1[_g];
            ++_g;
            v=p.position1.elements;
            v[0]=v[1]=v[2]=0;
            v=p.position2.elements;
            v[0]=v[1]=v[2]=0;
            p.depth = 0;
            p.id = 0;
        }
        v=this.normal.elements;
        v[0]=v[1]=v[2]=0;
    }
}